package com.sch.hospital.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.CrossOrigin;
import com.sch.hospital.domain.Result;
import com.sch.hospital.domain.Doctorwork;
import com.sch.hospital.service.IDoctorworkService;

/**
 * 医生工作经历Controller
 * 
 * @author ruoyi
 * @date 2025-06-30
 */
@RestController
@RequestMapping("/system/doctorwork")
@CrossOrigin
public class DoctorworkController
{
    @Autowired
    private IDoctorworkService doctorworkService;

    /**
     * 查询医生工作经历列表
     */

    @GetMapping("/list")
    public Result list(Doctorwork doctorwork)
    {
        List<Doctorwork> list = doctorworkService.selectDoctorworkList(doctorwork);
        return Result.success(list);
    }

    /**
     * 获取医生工作经历详细信息
     */

    @GetMapping(value = "/{id}")
    public Result getInfo(@PathVariable("id") Long id)
    {
        return Result.success(doctorworkService.selectDoctorworkById(id));
    }

    /**
     * 新增医生工作经历
     */

    @PostMapping
    public Result add(@RequestBody Doctorwork doctorwork)
    {
        int rows = doctorworkService.insertDoctorwork(doctorwork);
        return rows > 0 ? Result.success() : Result.error("新增医生工作经历失败");
    }

    /**
     * 修改医生工作经历
     */

    @PutMapping
    public Result edit(@RequestBody Doctorwork doctorwork)
    {
        int rows = doctorworkService.updateDoctorwork(doctorwork);
        return rows > 0 ? Result.success() : Result.error("修改医生工作经历失败");
    }

    /**
     * 删除医生工作经历
     */

    @DeleteMapping("/{ids}")
    public Result remove(@PathVariable Long[] ids)
    {
        int rows = doctorworkService.deleteDoctorworkByIds(ids);
        return rows > 0 ? Result.success() : Result.error("删除医生工作经历失败");
    }
}
